package environment;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;

/**
 * Circle obstacles
 * @author Toar
 *
 */
public class Obstacle implements EnvObjInterface 
{
	private String id;
	private Point p;
	private double r;
	private Rectangle bounds;
	private int x,y;
	
	/**
	 * 
	 * @param p
	 * @return
	 */
	public Obstacle(String id, int x, int y, double radius)
	{
		this.id = id;
		r = radius;
		this.x = x; this.y = y;
		/** x-r, y-r, is the topleft point of the bounding box (needed for Rectangle constructor) **/
		this.bounds = new Rectangle((int)(x-r),(int)(y-r),(int)(2*r),(int)(2*r));
		p = new Point((int)bounds.getCenterX(),(int)bounds.getCenterY());
	}
	
	public void draw(Graphics g) 
	{
		//g.setColor(Color.PINK);
	//	g.fillRect((int)(x-r),(int)(y-r),(int)(2*r),(int)(2*r));
		
		g.setColor(Color.RED);
		g.fillOval((int)(p.x-r),(int)(p.y-r),(int)(2*r),(int)(2*r));
        //g.fillOval((int) (p.x - r),-(int)(p.y + r), (int)(2*r),(int)(2*r));
		
	}

	public Rectangle getBounds() {
		return bounds;
	}

	public double getHeight() {
		// TODO Auto-generated method stub
		return 2*r;
	}

	public String getID() {
		return id;
	}

	public double getWidth() {
		return 2*r;
	}

	public int getX() {
		return p.x;
	}

	public int getY() {
		return p.y;
	}

	public boolean isPushable() {
		return false;
	}

	public boolean isTouching(int x, int y) {
		return bounds.contains(x, y);
	}

	public boolean isTouching(EnvObjInterface obj) {
		return bounds.intersects(obj.getBounds());
	}

	public void move(int howManyX, int howManyY, ArrayList<EnvObjInterface> a) 
	{
		/** obstacles cannot move **/
	}

	public void printStats() {
		// TODO Auto-generated method stub
		
	}

}
